# 绘制气泡图
import numpy as np
import matplotlib.pyplot as plt
num_vals = 40
# 生成随机值
# np.random.rand(n)返回n个服从0-1均值分布的值
x = np.random.rand(num_vals)
y = np.random.rand(num_vals)
# 定义每个气泡图中每个点的面积值
# 定义每个点的面积
# 指定最大半径
max_radius = 25
area = np.pi*(max_radius*np.random.rand(num_vals))**2
# 生成颜色
colors = np.random.rand(num_vals)
# 画出这些值
plt.scatter(x,y,s=area,c=colors,alpha=0.5)
plt.show()
